home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Development Tools & Languages / MacApp C++ Load⁄dump / DemoTextDump 2 / DemoText.r < prev    next >
Encoding:
Text File  |  1992-07-15  |  10.7 KB  |  425 lines  |  [TEXT/MPS ]

  1. /* Copyright © 1986-1990 by Apple Computer, Inc.  All rights reserved. */
  2.  
  3. /* • Auto-Include the requirements for this source */
  4. #ifndef __TYPES.R__
  5. #include "Types.r"
  6. #endif
  7.  
  8. #ifndef __MacAppTypes__
  9. #include "MacAppTypes.r"
  10. #endif
  11.  
  12. #if qTemplateViews
  13. #ifndef __ViewTypes__
  14. #include "ViewTypes.r"
  15. #endif
  16. #endif
  17.  
  18. #if qDebug
  19. include "Debug.rsrc";
  20. #endif
  21. include "MacApp.rsrc";
  22. include "Printing.rsrc";
  23.  
  24. include $$Shell("ObjApp")"DemoText" 'CODE';
  25.  
  26.  
  27. /* Resource ids */
  28.  
  29. #define kFileTooBig        1000                /* The 'File is too large' alert */
  30. #define kWindowRsrcID    1004
  31. #define kViewRsrcID        1005
  32.  
  33. #define kPromptsRsrcID    1005                /* STR# resource containing prompts */
  34.  
  35. #define mStyle               8                /* Hierarchical sub-menus */
  36. #define mSize               9
  37. #define mFont              10
  38. #define mColor              11
  39. #define hmStyle            "\0x08"                /* Byte values of hierarchical menu ids */
  40. #define hmSize            "\0x09"
  41. #define hmFont            "\0x0A"
  42. #define hmColor            "\0x0B"
  43.  
  44. #define kHierDisplayedMBar        131            /* MenuBar on hierarchical menu system */
  45.  
  46. /* Command numbers */
  47.  
  48. #define cWidthFrame         601                /* View-width-determination commands */
  49. #define cWidthView         602
  50. #define cWidthOnePage     603
  51.  
  52. #define cHeightFrame     604                /* View-height-determination commands */
  53. #define cHeightPages     605
  54. #define cHeightText         606
  55. #define cHeightConst     607
  56.  
  57. #define cJustLeft         608                /* Justification commands */
  58. #define cJustCenter         609
  59. #define cJustRight         610
  60.  
  61. #define cPlainText        1001                /* Typestyle attributes */
  62. #define cBold            1002
  63. #define cItalic         1003
  64. #define cUnderline        1004
  65. #define cOutline        1005
  66. #define cShadow         1006
  67. #define cCondense        1007
  68. #define cExtend         1008
  69.  
  70. #define cSizeChange     1100                /* Font-size commands */
  71. #define cSizeBase        1100
  72. #define cSizeMin        1109
  73. #define cSizeMax        1124
  74. #define cSizeGrow        1198
  75. #define cSizeShrink     1199
  76.  
  77. #define cJustChange     1200                /* Command numbers to cover other stylistic changes */
  78. #define cFontChange     1300
  79.  
  80. #define cStyle            1401                /* Command numbers for the hierarchial menu */
  81. #define cSize            1402
  82. #define cFont            1403
  83. #define cColor            1404
  84.  
  85. #define cColorChange    1500                /* Command numbers for changing colors */
  86. #define cColorText        1501
  87. #define cColorBackground 1502
  88.  
  89. #define kSignature        'SS04'                /* Application signature */
  90.  
  91. resource 'view' (kWindowRsrcID, purgeable) { {
  92.     root, 'WIND', { 50, 40 }, { 250, 450 }, sizeVariable, sizeVariable, shown, enabled,
  93.     Window {
  94.         "",
  95.             zoomDocProc, goAwayBox, resizable, modeless, ignoreFirstClick, freeOnClosing,
  96.             disposeOnFree, closesDocument, openWithDocument, dontAdaptToScreen, stagger,
  97.             forceOnScreen, dontCenter, 'TEVW', "" };
  98.  
  99.     'WIND', 'SCLR',    { 0, 0 }, { 250-kSBarSizeMinus1, 450-kSBarSizeMinus1 },
  100.     sizeRelSuperView, sizeRelSuperView, shown, enabled,
  101.     Scroller {
  102.         "",
  103.             vertScrollBar, horzScrollBar, 0, 0, 16, 16,
  104.             vertConstrain, horzConstrain, { 0, 0, 0, 0 } };
  105.     
  106.     'SCLR', IncludeViews { kViewRsrcID }
  107. } };
  108.  
  109.  
  110. resource 'view' (kViewRsrcID, purgeable) {{
  111.     root, 'TEVW', { 0, 0 }, { 116, 1020 }, sizeVariable, sizePage, shown, enabled,
  112.     TEView {
  113.         "",
  114.             withStyle, autoWrap, acceptChanges, dontFreeText, cTyping, unlimited,
  115.             { 8, 10, 0, 10 }, justLeft, applFont12 }
  116. } };
  117.  
  118.  
  119. resource 'STR#' (kPromptsRsrcID, purgeable) {
  120.     {
  121. /* [ 1] */    "Select a new text color…",
  122. /* [ 2] */    "Select background color…"
  123.     }
  124. };
  125.  
  126. resource 'SIZE' (-1) {
  127.     saveScreen,
  128.     acceptSuspendResumeEvents,
  129.     enableOptionSwitch,
  130.     canBackground,
  131.     MultiFinderAware,
  132.     backgroundAndForeground,
  133.     dontGetFrontClicks,
  134.     ignoreChildDiedEvents,
  135.     is32BitCompatible,
  136.     reserved,
  137.     reserved,
  138.     reserved,
  139.     reserved,
  140.     reserved,
  141.     reserved,
  142.     reserved,
  143. #if qdebug
  144.     450 * 1024,
  145.     368 * 1024
  146. #else
  147.     300 * 1024,
  148.     200 * 1024
  149. #endif
  150. };
  151.  
  152. /*    Printing to the LaserWriter is the time when the most temporary memory
  153.     is in use.  We need the segments in use at that time */
  154.  
  155. resource 'seg!' (256, purgeable) {
  156.     {
  157.         "GWriteFile";
  158.         "GClipboard";
  159.         "GNonRes";
  160.         "GFile";
  161.         "GSelCommand";
  162.         "GTerminate";
  163.         "GClose";
  164.         "GDoCommand";
  165.     }
  166. };
  167.  
  168. resource 'DITL' (phAboutApp, purgeable) {
  169.      {
  170. /* [ 1] */    {160, 182, 180, 262},
  171.             Button {
  172.                 enabled,
  173.                 "OK"
  174.             };
  175. /* [ 2] */    {10, 75, 150, 320},
  176.             StaticText {
  177.                 disabled,
  178.                     "This sample program demonstrates how to use various features of "
  179.                     "the “TEView” building block of MacApp.\n\nThis program was written "
  180.                     "with MacApp® © 1985-1990 Apple Computer, Inc."
  181.             };
  182. /* [ 3] */    {10, 20, 42, 52},
  183.             Icon {
  184.                 disabled,
  185.                 1
  186.             }
  187.     }
  188. };
  189.  
  190. include "Defaults.rsrc"  'ALRT' (phAboutApp);    // Grab the default about box
  191.  
  192. /* Used when the user attempts to read a file larger than we can handle */
  193.  
  194. resource 'DITL' (kFileTooBig, purgeable) {
  195.     {
  196. /* [ 1] */    {82, 198, 100, 272},
  197.                 Button {
  198.                     enabled,
  199.                     "OK"
  200.                 };
  201. /* [ 2] */    {10, 70, 77, 272},
  202.                 StaticText {
  203.                     disabled,
  204.                     "DemoText can’t read the entire file because it is too long."
  205.                 };
  206. /* [ 3] */    {10, 20, 42, 52},
  207.                 Icon {
  208.                     disabled,
  209.                     0
  210.                 }
  211.     }
  212. };
  213.  
  214. resource 'ALRT' (kFileTooBig, purgeable) {
  215.     {100, 110, 210, 402},
  216.     kFileTooBig,
  217.     {
  218. /* [ 1] */    OK, visible, silent;
  219. /* [ 2] */    OK, visible, silent;
  220. /* [ 3] */    OK, visible, silent;
  221. /* [ 4] */    OK, visible, silent
  222.     }
  223. };
  224.  
  225. include "Defaults.rsrc" 'cmnu' (mApple);        // Grab the default Apple/File menus
  226. include "Defaults.rsrc" 'cmnu' (mFile);
  227.  
  228. resource 'cmnu' (mEdit) {
  229.     mEdit,
  230.     textMenuProc,
  231.     AllEnabled,
  232.     enabled,
  233.     "Edit",
  234.      {
  235. /* [ 1] */    "Undo",                noIcon,    "Z",    noMark,    plain,    cUndo;
  236. /* [ 2] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  237. /* [ 3] */    "Cut",                noIcon,    "X",    noMark,    plain,    cCut;
  238. /* [ 4] */    "Copy",                noIcon,    "C",    noMark,    plain,    cCopy;
  239. /* [ 5] */    "Paste",            noIcon,    "V",    noMark,    plain,    cPaste;
  240. /* [ 6] */    "Clear",            noIcon,    noKey,    noMark,    plain,    cClear;
  241. /* [ 7] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  242. /* [ 8] */    "Select All",        noIcon,    "A",    noMark,    plain,    cSelectAll;
  243. /* [ 9] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  244. /* [10] */    "Show Clipboard",    noIcon,    noKey,    noMark,    plain,    cShowClipboard;
  245. /* [11] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  246. /* [12] */    "Show Page Breaks",    noIcon, noKey,    noMark,    plain,    cShowBreaks
  247.     }
  248. };
  249.  
  250. resource 'cmnu' (5) {
  251.     5,
  252.     textMenuProc,
  253.     AllEnabled,
  254.     enabled,
  255.     "Text",
  256.      {
  257. /* [ 1] */    "View as wide as frame",
  258.                                 noIcon,    noKey,    noMark,    plain,    cWidthFrame;
  259. /* [ 2] */    "View width frozen",
  260.                                 noIcon,    noKey,    noMark,    plain,    cWidthView;
  261. /* [ 3] */    "View as wide as one page",
  262.                                 noIcon,    noKey,    noMark,    plain,    cWidthOnePage;
  263. /* [ 4] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  264. /* [ 5] */    "View as high as the frame",
  265.                                 noIcon,    noKey,    noMark,    plain,    cHeightFrame;
  266. /* [ 6] */    "View height an exact number of pages",
  267.                                 noIcon,    noKey,    noMark,    plain,    cHeightPages;
  268. /* [ 7] */    "View as high as its content",
  269.                                 noIcon,    noKey,    noMark,    plain,    cHeightText;
  270. /* [ 8] */    "View height frozen",
  271.                                 noIcon,    noKey,    noMark,    plain,    cHeightConst;
  272. /* [ 9] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  273. /* [10] */    "Left justified",    noIcon,    noKey,    noMark,    plain,    cJustLeft;
  274. /* [11] */    "Center justified",    noIcon,    noKey,    noMark,    plain,    cJustCenter;
  275. /* [12] */    "Right justified",    noIcon,    noKey,    noMark,    plain,    cJustRight
  276.     }
  277. };
  278.  
  279. /* Hierarchical  Format menu with Style, Size and Font submenus */
  280. resource 'cmnu' (7) {
  281.     7,
  282.     textMenuProc,
  283.     allEnabled,
  284.     enabled,
  285.     "Format",
  286.      {
  287. /* [ 1] */    "Style",            noIcon, kHierarchicalMenu, hmStyle, plain, cStyle;
  288. /* [ 2] */    "Size",                noIcon, kHierarchicalMenu, hmSize, plain, cSize;
  289. /* [ 3] */    "Font",                noIcon, kHierarchicalMenu, hmFont, plain, cFont;
  290. /* [ 4] */    "Color",            noIcon, kHierarchicalMenu, hmColor, plain, cColor
  291.     }
  292. };
  293.  
  294. /* Hierarchical Style Sub-menu */
  295. resource 'cmnu' (mStyle) {
  296.     mStyle,
  297.     textMenuProc,
  298.     allEnabled,
  299.     enabled,
  300.     "Style",
  301.      {
  302. /* [ 1] */    "Plain Text",        noIcon,    noKey,    noMark,    plain,        cPlainText;
  303. /* [ 2] */    "Bold",                noIcon,    noKey,    noMark,    bold,        cBold;
  304. /* [ 3] */    "Italic",            noIcon,    noKey,    noMark,    italic,        cItalic;
  305. /* [ 4] */    "Underline",        noIcon,    noKey,    noMark,    underline,    cUnderline;
  306. /* [ 5] */    "Outline",            noIcon,    noKey,    noMark,    outline,    cOutline;
  307. /* [ 6] */    "Shadow",            noIcon,    noKey,    noMark,    shadow,        cShadow;
  308. /* [ 7] */    "Condensed",        noIcon,    noKey,    noMark, condense,    cCondense;
  309. /* [ 8] */    "Extended",            noIcon,    noKey,    noMark, extend,        cExtend
  310.     }
  311. };
  312.  
  313. /* Hierarchical Size Sub-menu */
  314. resource 'cmnu' (mSize) {
  315.     mSize,
  316.     textMenuProc,
  317.     AllEnabled,
  318.     enabled,
  319.     "Size",
  320.      {
  321. /* [ 1] */    " 9 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+9;
  322. /* [ 2] */    "10 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+10;
  323. /* [ 3] */    "12 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+12;
  324. /* [ 4] */    "14 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+14;
  325. /* [ 5] */    "18 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+18;
  326. /* [ 6] */    "24 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+24;
  327. /* [ 7] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  328. /* [ 8] */    "Grow selection",    noIcon,    "]",    noMark,    plain,    cSizeGrow;
  329. /* [ 9] */    "Shrink selection",    noIcon,    "[",    noMark,    plain,    cSizeShrink
  330.  
  331.      }
  332. };
  333.  
  334. /* Font menu for hierarchical or non-hierarchical system */
  335. resource 'MENU' (mFont) {
  336.     mFont,
  337.     textMenuProc,
  338.     allEnabled,
  339.     enabled,
  340.     "Font",
  341.     { }
  342. };
  343.  
  344. resource 'cmnu' (mColor) {
  345.     mColor,
  346.     textMenuProc,
  347.     allEnabled,
  348.     enabled,
  349.     "Color",
  350.     {
  351. /* [ 1] */    "Set text color…",    noIcon,    "T",    noMark,    plain,    cColorText;
  352. /* [ 2] */    "Set background color…",
  353.                                 noIcon,    "K",    noMark,    plain,    cColorBackground
  354.     }
  355. };
  356.  
  357. resource 'cmnu' (mBuzzwords) {
  358.     mBuzzwords,
  359.     textMenuProc,
  360.     allEnabled,
  361.     enabled,
  362.     "Buzzwords",
  363.     {
  364.         "Typing",                noIcon,    noKey,    noMark,    plain,    cTyping;
  365.         "Style Change",            noIcon,    noKey,    noMark,    plain,    cStyleChange;
  366.         "Size Change",            noIcon,    noKey,    noMark,    plain,    cSizeChange;
  367.         "Justification Change",    noIcon,    noKey,    noMark,    plain,    cJustChange;
  368.         "Font Change",            noIcon,    noKey,    noMark,    plain,    cFontChange;
  369.         "Color Change",            noIcon,    noKey,    noMark,    plain,    cColorChange;
  370.         "Page Setup Change",    noIcon,    noKey,    noMark,    plain,    cChangePrinterStyle
  371.     }
  372. };
  373.  
  374. /* Displayed menus on a non-hierarchical system */
  375. resource 'MBAR' (kMBarDisplayed) {
  376.     {mApple; mFile; mEdit; 5; 8; 9; 10; 11}
  377. };
  378.  
  379. /* Displayed menus on a hierarchical system */
  380. resource 'MBAR' (kHierDisplayedMBar) {
  381.     {mApple; mFile; mEdit; 5; 7}
  382. };
  383.  
  384. /* Hierarchial Sub-Menus */
  385. resource 'MBAR' (kMBarHierarchical) {
  386.     {8; 9; 10; 11}
  387. };
  388.  
  389. include "Defaults.rsrc"  'STR#' (kDefaultCredits);        // Grab the default credits
  390. resource 'BNDL' (128,
  391. #if qNames
  392. "DemoText",
  393. #endif
  394.     purgeable) {
  395.     kSignature,
  396.     0,
  397.     {
  398.         'ICN#',
  399.         {
  400.             0, 128,
  401.         },
  402.         'FREF',
  403.         {
  404.             0, 128,
  405.         }
  406.     }
  407. };
  408.  
  409. type kSignature as 'STR ';
  410. resource kSignature (0,
  411. #if qNames
  412. "Signature",
  413. #endif
  414.     purgeable) {
  415.     "DemoText 2.0 ©Apple Computer, Inc. 1988-1990"
  416. };
  417.  
  418. // Get the default MacApp® application icon and file reference
  419. include "Defaults.rsrc"  'ICN#' (128);
  420. include "Defaults.rsrc"  'FREF' (128);
  421.  
  422. // Get the default Version resources
  423. include "Defaults.rsrc"  'vers' (1);        // Application or file specific
  424. include "Defaults.rsrc"  'vers' (2);        // Overall package
  425.